<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
    <script src="./js/vue.js"></script>
    <title>Document</title>
    <style>
        #app {
            width: 500px;
            height: 400px;
            margin: 0px auto;
            position: relative;
            overflow: hidden;
        }

        #app>div {
            width: 200px;
            height: 200px;
            margin: 10px auto;
            background-color: skyblue;
            position: absolute;
            top: 20px;
            left: 0px;
            line-height: 200px;
            font-size: 40px;
            text-align: center;
            display: none;
        }

        :root {
            --animate-duration: 2s;
        }
    </style>
</head>

<body>
    <div id="app" class="">
        <!-- <h2 v-show="!flag">这是一个v-show</h2>
        <h2 v-show="!flag">这是一个v-show</h2> -->
        <button @click="changeFlag(0)">隐藏显示</button>
        <button @click="changeFlag(1)">隐藏显示</button>
        <button @click="changeFlag(2)">隐藏显示</button>
        <div class="box animate__animated   " style="display: block; z-index: 2;">页面1</div>
        <div class="box animate__animated animate__backOutLeft  ">页面2</div>
        <div class="box animate__animated  animate__backOutLeft ">页面3</div>
        <!-- <button @click="flag=2">隐藏显示</button>
        <button @click="flag=3">隐藏显示</button>
        <button @click="flag=4">隐藏显示</button>
        <div v-show="flag==2" class="box animate__animated  animate__backOutLeft animate__bounceInRight">页面1</div>
        <div v-show="flag==3" class="box animate__animated animate__backOutLeft  animate__bounceInRight ">页面2</div>
        <div v-show="flag==4" class="box animate__animated  animate__backOutLeft animate__bounceInRight ">页面3</div> -->
    </div>
</body>
<script>
    // import 'animate.css';
    const vm = new Vue({
        el: "#app",
        data: {
            flag: true
        },
        methods: {
            changeFlag(a) {
                console.log(a);
                let boxEle = document.querySelectorAll(".box");
                boxEle.forEach(function (item, index) {
                    item.style.display = "block"
                    if (index != a) {
                        item.classList.remove("animate__bounceInRight")
                        item.classList.add("animate__backOutLeft");
                    }
                })
                boxEle[a].classList.remove("animate__backOutLeft");
                boxEle[a].classList.add("animate__bounceInRight")
            }
        }
    })

</script>

</html>